﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>用户管理</title>
    <script src="../../Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
     <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />

    <script src="../../Content/JS/layer-v1.7.1/layer/layer.js" type="text/javascript"></script>
     <style type="text/css">
      .ShowTable{ overflow:scroll; }
      .UsersTabel{ border-color:#1C1C1C; height: 100%; width:100%;overflow:scroll;text-align:center; border-collapse:collapse; border-spacing:0; margin-bottom:10px;}
      .UsersTabel th,td{ word-break:keep-all; white-space:nowrap;  border:1px black solid ; padding:3px;}
      .pager{ margin-left:30%;  padding-top:20px;}
      .ShowBtn{ text-align:right; margin-right:10px;}
       .vmenu{
		border:1px solid #aaa;
		position:absolute;
		background:#fff; 
		text-align:center;
		display:none;font-size:12px;}
		.first_li{}
		.first_li span{width:100px;display:block;padding:5px 10px;cursor:pointer}
		.inner_li{display:none;margin-left:120px;position:absolute;border:1px solid #aaa;border-left:1px solid #ccc;margin-top:-28px;background:#fff;}
		.sep_li{border-top: 1px ridge #aaa;margin:5px 0}
		.fill_title{font-size:11px;font-weight:bold;/height:15px;/overflow:hidden;word-wrap:break-word;}
		.fieldCss{ border: solid 1px #C6E2FF;width: 250px;padding: 10px 10px 10px 10px;}
		#UserSelect{ margin-left:10px; margin-top:10px;}
     </style>
</head>
<body class="main">
    <div class="AllWebTopDiv" >
         <div class="path">
             <div class="nav">
               <a href="#">用户管理</a>
               <div class="ShowBtn">
               <input  type="button" id="UserSale" value="用户消费" class="button2"/>
               <input  type="button" id="UserRe" value="用户注册" class="button2"/>
               <input  type="button" id="UserSearch" onclick="userSelect()" value="查询" class="button2"/>
                <input  type="button" id="UserLev" value="升为会员" class="button2"/>
                <input type="button"  id="UserDaoChu" value="导出" class="button2" onclick="daochu()"/> 
                <input  type="button" id="exit" value="关闭" onclick="closeWindows();"  class="button2"/>
               </div>
             </div>
        </div>
       <div class="content">
       <div class="ShowTable">
        <table id="ShowData" border="1"  class="UsersTabel">

         </table>
          <div class="vmenu">

						<div class="first_li"><span id="XG" onmousemove="fs(this)"; onmouseout="fx(this)" onclick="userUpdate()">修改</span></div>

                        <div class="first_li"><span id="GS" onmousemove="fs(this)"; onmouseout="fx(this)" onclick="userSelect()">查询</span></div>
                       
                        <div class="first_li"><span id="SC" onmousemove="fs(this)"; onmouseout="fx(this)" onclick="userDel()">删除</span></div>
					</div>
       </div>
           
         <div class="pager">
         <input  type="button" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('首页')"style="cursor:pointer"  value="首页" class="button"/>
         <input type="button" value="上一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('上一页')"style="cursor:pointer" class="button"/>
         <input type="button" value="下一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('下一页')"style="cursor:pointer" class="button"/>
         <input type="button" value="末页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('末页')"style="cursor:pointer" class="button"/>
      
       　共 <label id="maxPage">1</label> 页 第 <label id="CurrentPage">1</label> 页
       </div>
       </div>
        
                
   </div>
</body>
</html>
<script type="text/javascript">
 document.oncontextmenu=function(){return false;}
     var pageNum=1;
     var pageSize=20;
 $.ajax({
            type:"POST",
            url:"<%:Url.Action("LoadData","UserManager") %>",
            data:"pageSize="+pageSize,
            cache:false,
            success:function(html)
            {
    
                $("#ShowData").html(html);
                newPage("首页");
            }
           })
               $.ajax({
            type:"POST",
            url:"<%:Url.Action("Data_Load_maxPage","UserManager") %>",
            data:"pageSize="+pageSize,
            cache:false,
            success:function(html)
            {
                $("#maxPage").html(html);
               
            }
        })

        function newPage(sa)
        {
           var CurrentPage= $("#CurrentPage").html();
             var maxPage=$("#maxPage").html();
           
            maxPage=parseInt(maxPage);
            
            
            if(sa=="首页")
            {
                pageNum=1;
               document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="下一页")
            {
                 if(CurrentPage>=maxPage)
                {
                     alert("已是最大页数");
                    return;
                }
                pageNum++;
                document.getElementById("CurrentPage").innerHTML=pageNum;
               
            }
            if(sa=="上一页")
            {
                 if(CurrentPage==1)
            {
                alert("已是最小页数");
                return;
            } 
                pageNum--;
                document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="末页")
            {
                pageNum=maxPage;
                 document.getElementById("CurrentPage").innerHTML=pageNum;
            }
              $.ajax({
                type:"POST",
                url:"<%:Url.Action("newPage","UserManager") %>",
                data:"pageNum="+pageNum+"&pageSize="+pageSize+"",
                cache:false,
                success:function(html)
                {
                $("#ShowData").html(html); 
                }
            })
        }
   
      
      //用户消费窗口
       $("#UserSale").on('click', function () {
            $.layer({
              type: 2,
              title: false,
              closeBtn:false,
              shadeClose: true, //开启点击遮罩关闭层
              move: ['.juanmove', true],
              area: ['800px', '460px'],
              offset: ['100px', ''],
              iframe: { src: '<%:Url.Action("UserSale","UserManager") %>' },
              success:function(){
                layer.shift('top',500)
              }
          });
      });
       //用户注册窗口
      
       $("#UserRe").on('click', function () {
          var UpdateUser= $.layer({
              type: 2,
              title: false,
              closeBtn:false,
              shadeClose: true, //开启点击遮罩关闭层
              move: ['.juanmove', true],
              area: ['1000px', '460px'],
              offset: ['100px', ''],
              iframe: { src: '<%:Url.Action("UpdateUser","UserManager") %>' },
              success:function(){
                layer.shift('top',500)
              }
          });
            
      });
       function fs(xz)
        {
            $(xz).css("background-color","#E0EDFE");
        }
        function fx(bz)
        {
            $(bz).css("background-color","#FFFFFF");
        }
        var UserId="";
        //获取右击菜单
        function vc(o,e){
          
          var e= e||window.event;
          var x= e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
          var y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
          $(".vmenu").css("left",x).css("top",y).css("display","block");
          UserId=o;
         // setTimeout(function(){$(".vmenu").css("display","none"); },5000);
        }
        //关闭右键菜单
        function closeContext(){
          $(".vmenu").css("display","none");
        }

       //更新用户
        function userUpdate(){
            $(".vmenu").css("display","none");
              var UpdateUser= $.layer({
              type: 2,
              title: false,
              closeBtn:false,
              shadeClose: true, //开启点击遮罩关闭层
              move: ['.juanmove', true],
              area: ['1000px', '460px'],
              offset: ['100px', ''],
              iframe: { src: '/UserManager/editUser/?UserId='+UserId },
              success:function(){
                layer.shift('top',500)
              }
          });
              
            
        }
        //用户查询窗口
        function userSelect(){
          $(".vmenu").css("display","none");
          var html="<div id=\"UserSelect\"><div class=\"path\"><div class=\"nav\"><a href=\"#\">用户查询</a></div></div><div class=\"content\"><fieldset class=\"fieldCss\"><legend>查询条件</legend><form id=\"userMsg\"><label>用户编号：</label><input type=\"text\" id=\"UserId\" /><br /><br /><label>用户姓名：</label><input type=\"text\" id=\"UserName\" /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<label>性别：</label><input type=\"text\" id=\"Sex\" /><br /><br /><label>手机号码：</label><input type=\"text\" id=\"mobile\" /><br /><br /></form></fieldset><div><input  type=\"button\" value=\"查询\" onclick=\"selectByInput()\" class=\"button2\" style=\"margin-left:50px;\"/><input  type=\"button\" value=\"关闭\" onclick=\"layer.closeAll()\" class=\"button2\" style=\"margin-left:50px;\"/></div></div></div>";
             $.layer({
                    type: 1,
                    title: false,
                    closeBtn:false,
                    offset:['400px', '400px'],
                    area: ['370px', '260px'],
                    shade: [0],
                    page: {
                        html: html
                    }, success: function(){
                        layer.shift('top');

                    }
                });
        }

        //用户查询方法
        function selectByInput()
        {
               var UserId = $("#UserId").val();
               var UserName = $("#UserName").val();
               var Sex = $("#Sex").val();
               var mobile = $("#mobile").val();
               
                $.ajax({
                             type:"POST",
                              url:"<%:Url.Action("UserSelect","UserManager") %>",
                             data:"UserId="+UserId+"&UserName="+UserName+"&Sex="+Sex+"&mobile="+mobile+"",
                             cache:false,
                             success:function(html){
                                     $("#ShowData").html(html); 
                                     layer.closeAll();
                                     $(".pager").css("display","none");
                                 }
                            })
        }

        //导出会员信息
      


        //删除用户
          function userDel()
          {
            $(".vmenu").css("display","none");
              $.layer({
                  shade:[0.5,'#000',true],
                  area:['310px', '130px'],
                  dialog:{
                      msg:'您确定要删除该用户吗',
                      btns:2,
                      type:4,
                      btn: ['确定','取消'],
                      yes:function(){
                          $.ajax({
                             type:"POST",
                              url:"<%:Url.Action("DelMember","UserManager") %>",
                             data:"UserId="+UserId+"",
                             cache:false,
                             success:function(txt){
                              layer.msg(txt,2,function(){location.reload('<%:Url.Action("UserInfo","UserManager") %>');});
                                 }
                            })

                      },no:function(){
                         layer.closeAll();
                      }
                  }
              
              });
          }

          //导出
      function daochu(){
      window.open('<%:Url.Action("UserToExcel","UserManager") %>');
      }
      
     //关闭窗口
       function closeWindows()
    {
     window.location.href = "/Loading/Index/?src=/Desktop/Index/";
    }
 
</script>
